<?php

namespace App\Http\Requests\Mini\Meter;


use Illuminate\Foundation\Http\FormRequest;

class CollectorMeter extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * 2021/3/10--13:13
     * @return string[]
     * @author:苏冬冬
     * @method:rules
     * @effect: 添加采集器验证
     */
    public function rules()
    {
        return [
            'name' => 'required',
            'code' => ['required','regex:/^[a-z\d]*$/i'],
            'community_id' => 'required',
            'agent_id' => 'required',
        ];
    }

    /**
     * @return array|void
     */
    public function messages()
    {
        return [
            'name.required' => '请填写采集器名称',
            'code.required' => '请填写采集器编码',
            'code.regex' => '采集器编码必须为字母或数字组合',
            'community_id.required' => '请选择区域',
            'agent_id.required' => '请选择代理商',
        ];
    }
}
